<!-- 首页 -->
<template>
    <view class="home-wrap u-m-b-20">

        <!-- #ifdef APP-PLUS -->
        <u-no-network @retry="init"></u-no-network>
        <!-- #endif -->
        <view class="content-box">
            <view>

                <view class="u-flex u-flex-col u-w-100s">
                    <view class="userInfo u-flex u-row-between u-col-center u-w-100s">
                        <view class="userleft u-flex u-row-left u-col-center u-w-100s u-p-l-20">
                            <view class="usertitle">任务详情</view>
                        </view>
                    </view>

                    <view class="collect-list u-w-100s">
                        <view class="zixun-item u-flex u-flex-col u-p-l-20 u-p-r-20">
                            <view class="u-flex u-row-between u-flex-col u-col-center u-w-100s">
                                <view class="u-flex u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">任务名称:</view>
                                    <view class="kehulsit u-ellipsis-1 u-m-l-10">100个仰卧起坐</view>
                                </view>

                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">体测项目:</view>
                                    <view class="kehulsit u-ellipsis-1 u-m-l-10">仰卧起坐</view>
                                </view>
                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">任务模式:</view>
                                    <view class="kehulsit u-flex u-m-l-10">
                                        训练模式
                                    </view>
                                </view>
                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">考核标准:</view>
                                    <view class="kehulsit u-flex u-m-l-10">
                                        仰卧起坐
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>

                </view>
                <view class="u-flex u-flex-col u-w-100s">
                    <view class="userInfo u-flex u-row-between u-col-center u-w-100s">
                        <view class="userleft u-flex u-row-left u-col-center u-w-100s u-p-l-20">
                            <view class="usertitle">任务成绩</view>
                        </view>
                    </view>
                    <view class="collect-list u-w-100s">
                        <view class="zixun-item u-flex u-flex-col u-p-l-20 u-p-r-20">
                            <view class="u-flex u-row-between u-flex-col u-col-center u-w-100s">
                                <view class="u-flex u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">运动成绩:</view>
                                    <view class="kehulsit u-ellipsis-1 u-m-l-10">‘0’49’</view>
                                </view>

                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">运动耗时:</view>
                                    <view class="kehulsit u-ellipsis-1 u-m-l-10">‘0’41’</view>
                                </view>
                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">运动评分:</view>
                                    <view class="kehulsit u-flex u-m-l-10">
                                        80
                                    </view>
                                </view>
                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item  task-items">
                                    <view class="kehulsit u-ellipsis-1">运动评定:</view>
                                    <view class="kehulsit u-flex u-m-l-10  task-item-color">
                                        良好
                                    </view>
                                </view>
                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">班级排名:</view>
                                    <view class="kehulsit u-flex u-m-l-10">
                                        12/55
                                    </view>
                                </view>
                                <view class="u-flex  u-row-between u-col-center u-w-100s task-item">
                                    <view class="kehulsit u-ellipsis-1">参与时间:</view>
                                    <view class="kehulsit u-flex u-m-l-10">
                                        2023-09-10 12:50
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>

            </view>
            <!-- 权限验证 -->
            <u-popup v-model="showTetel" mode="center" border-radius="20" :closeable="true" close-icon-pos="top-right">
                <view class="notice-modal">
                    <view class="notice-title">{{ "是否拨打"+telenum }}</view>
                    <view class="u-flex u-row-around u-w-100s">
                        <button class="u-reset-button back-btn" @tap="showTetel=false">取消</button>
                        <button class="u-reset-button notice-btn" @tap="$tools.callPhone(telenum)">确认</button>

                    </view>
                </view>
            </u-popup>
        </view>
        <!-- <shopro-tabbar></shopro-tabbar> -->
    </view>
</template>

<script>

let systemInfo = uni.getSystemInfoSync();
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
export default {
    components: {

    },
    data() {
        return {
            customers_id:'',
            showTetel:false,
            telenum:'18135140898',
            keyword:'',
            kehu:
                {

                },
            kehuDetail:[],
            isEmpty:false,
            searchVal:'',
            loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
            currentPage: 1,
            lastPage: 1,
            stickyTop: 0,
            show:false,
            colorArr   : ['#00BFFF', '#4ff279', '#FFC1C1', '#E066FF', '#FF7F00','#FF34B3']
        };
    },
    computed: {

    },
    async onLoad() {
        this.customers_id    = this.$Route.query.customers_id;
        this.getmykehu()
    },
    created(){

        this.getmyKehuDetail();
        // 触底监听
        uni.$on('uOnReachBottom', data => {
            if (this.currentPage < this.lastPage) {
                this.currentPage += 1;
                this.getmyKehuDetail();
            }
        });
    },
    onPullDownRefresh() {
        // this.init();
    },
    oonPageScroll(e) {

    },
    onShow() {
        let that = this;

        // this.showtabbar()
    },
    onHide() {

    },
    mounted() {

    },

    watch: {

    },
    methods: {

        getmykehu(){
            let that = this;
            that.$http('login.customer_info', {
                customers_id: that.customers_id
            }).then(res => {
                if (res.code === 1) {
                    let phone           = JSON.parse(JSON.stringify(res.data.phone))
                    res.data.phones         = phone.replace(/^(\d{3})\d{4}(\d+)/, "$1****$2");
                    res.data.names = res.data.name.charAt(0) + that.idCard(res.data.idcard)
                    that.kehu = res.data;
                }
            });
        },
        //通过身份证号计算性别
        idCard(userCard) {
            //获取性别
            if (parseInt(userCard.substr(16, 1)) % 2 == 1) {
                return "男士";
            } else {
                return "女士";
            }

        },

        telphone(num){
            this.showTetel = true;
            this.telenum = num
        },
        // 初始化
        init() {
            this.isRefresh = false;
        },

        // 路由跳转
        jump(path, parmas) {
            console.log('-----11111');
            this.$Router.push({
                path: path,
                query: parmas
            });
        },
        // 商品列表
        getmyKehuDetail() {
            let that = this;
            that.$http('login.customer_portray', {
                customers_id: that.customers_id,
                page: that.currentPage,
                pagesize:10
            }).then(res => {
                if (res.code === 1) {
                    res.data.data.map((item,index)=>{
                        item.leixing = item.text.split(',')
                    })
                    res.data.data.map((item,index)=>{
                        item.attrs = item.attr.split(',')
                    })
                    that.kehuDetail = [...that.kehuDetail, ...res.data.data];
                    that.isEmpty = !that.kehuDetail.length;
                    that.lastPage = res.data.last_page;
                    that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
                }
            });
        },
    }
};
</script>

<style lang="scss">
.home-wrap{
}
.bianji{
    width: 90%;
    background: #0081ff;
    border-radius: 30rpx;
    color:#fff;
}
.input-item{
    color:#333;
    margin:20rpx 0rpx 20rpx 20rpx;
    height: 64rpx;
    background: #FFFFFF;
    border-radius: 30rpx;
    text-indent: 14rpx;
}
//nav
.zixun-item {
    border-radius: 20rpx;
    background: #fff;

    .zixuntitle {
        color: #333;
        font-size: 28rpx;
    }

    .zixunimg {
        width: 100%;
        height: 180rpx;

        image {
            width: 100%;
            height: 100%;
        }
    }

    .zixuntime {
        color: #cccccc;
        font-size: 24rpx;
    }

    .yichu {
        padding: 16rpx 26rpx;
        border-radius: 34rpx;
        background: #0081ff;
        color: #fff;
    }

    .tag {
        color: #fff;
        padding: 6rpx 18rpx;
        font-size: 20rpx;
        border-radius: 20rpx;
        border: 2rpx solid transparent;
        margin-right: 10rpx;
    }
}
.userInfo{
    .userleft{
        background: #F5F5F5;
        padding:20rpx 20rpx;
        .usertitle{
            font-size:30rpx;
        }
    }
    .userright{
        padding:10rpx 24rpx;
        background: #0081ff;
        border-radius: 30rpx;
        color: #FFFFFF;
    }

}
// 提示
.notice-modal {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 85vw;
    min-height: 358rpx;
    background: #ffffff;
    padding: 30rpx;
    border-radius: 20rpx;

    .notice-title {
        width: 100%;
        font-size: 30rpx;
        font-weight: bold;
        color: #46351b;
        text-align: center;
    }

    .notice-detail {
        font-size: 24rpx;
        font-weight: 400;
        color: #999999;
        line-height: 36rpx;
        margin-bottom: 50rpx;
    }

    .back-btn {
        width: 45%;
        height: 70rpx;
        line-height: 70rpx;
        background: #f8f8f8;
        box-shadow: 0 7rpx 8rpx 2rpx #ccc;
        border-radius: 35rpx;
        font-size: 26rpx;
        font-weight: 500;
        color: #333;
        margin-bottom: 10rpx;
    }

    .notice-btn {
        width: 45%;
        height: 70rpx;
        line-height: 70rpx;
        font-size: 26rpx;
        font-weight: 500;
        color: #fff;
        border-radius: 35rpx;
        background: linear-gradient(90deg, #3357DB 0%, #3469E1 47%, #3597F1 100%);
        box-shadow: 0 7rpx 8rpx 2rpx #3597F1;
    }
}
.task-item{
    padding: 20rpx 0;
    border-bottom:2rpx solid #f5f5f5;
    .icon-phone{
        width: 80rpx;
        height: 80rpx;
    }
    .kehulsit{
        &:first-child{
            color:#8E8E8E;
        }
    }
}
</style>
